import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'mybutton.dart';
import 'main.dart';

class LoginPageStatelessWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "登录页面",
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.blue),
      home: new LoginPageStatefulWidget(),
    );
  }
}

class LoginPageStatefulWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new LoginPageState();
  }
}

class LoginPageState extends State {
  var _userPassController = new TextEditingController();
  var _userNameController = new TextEditingController();

  void _login() {
    var string = _userPassController.toString();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new SafeArea(
          child:SingleChildScrollView(child:
          Wrap(
            children: <Widget>[
              Container(
                child: Padding(
                    padding: EdgeInsets.only(top: 50),
                    child: MyButton(
                        pressed: () {
                          Navigator.of(context)
                              .push(new MaterialPageRoute(builder: (context) {
                            return new MyApp();
                          }));
                        },
                        icon: Icon(
                          Icons.navigate_next,
                          color: Color(0xffacacac),
                        ),
                        label: Text("立即注册",
                            style: TextStyle(
                                fontSize: 15, color: Color(0xffacacac))))),
                alignment: Alignment.topRight,
              ),
              Container(
                alignment: Alignment.topLeft,
                child: Padding(
                  padding: EdgeInsets.only(top: 30, left: 30),
                  child: Text(
                    '欢迎来到猫扑',
                    style: TextStyle(
                        fontSize: 24,
                        color: Color(0xff303133),
                        fontWeight: FontWeight.bold),
                  ),
                ),
              ),
              Container(
                padding: EdgeInsets.only(left: 30, right: 20),
                child: Column(
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.only(top: 100.0),
                      child: TextField(
                        enabled: true,
                        controller: _userNameController,
                        decoration: new InputDecoration(
                            contentPadding: EdgeInsets.only(bottom: 5),
                            labelText: "用户名",
                            hintText: "请输入用户名"),
                        keyboardType: TextInputType.text,
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.only(top: 32.0),
                      child: TextField(
                        obscureText: true,
                        controller: _userPassController,
                        decoration: new InputDecoration(
                            contentPadding: EdgeInsets.only(bottom: 5),
                            labelText: "密码",
                            hintText: "请输入用户密码"),
                        keyboardType: TextInputType.visiblePassword,
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.only(top: 5),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: <Widget>[
                          Text(
                            "忘记密码",
                            style:
                            TextStyle(fontSize: 12, color: Color(0xffc6cbd6)),
                          )
                        ],
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.only(top: 85),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          FlatButton(
                            padding: EdgeInsets.only(top: 10, bottom: 10),
                            onPressed: _login,
                            color: Color(0xff3C98FF),
                            child: Text(
                              '登录',
                              style: TextStyle(color: Colors.white, fontSize: 18),
                            ),
                            shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(22.5)),
                          )
                        ],
                      ),
                    ),
                    Padding(
                        padding: EdgeInsets.only(top: 40),
                        child: Column(
                          children: <Widget>[
                            Text(
                              '游客登录',
                              style: TextStyle(
                                  fontStyle: FontStyle.normal,
                                  fontSize: 15,
                                  color: Color(0xff585858),
                                  decoration: TextDecoration.underline),
                            ),
                          ],
                        ))
                  ],
                ),
                alignment: Alignment.center,
              )
            ],
          ),)),
    );
  }
}
